/* function create <T> (c:{new ():T}):T{
  return new c()
} */

class BeeKeeper {
  hasMask: boolean = true
}

class ZooKeeper {
  nametag: string = 'Mikle'
}

class Animal {
  bymLegs: number = 4
}

class Bee extends Animal {
  keeper: BeeKeeper = new BeeKeeper()
}

class Lion extends Animal {
  keeper: ZooKeeper = new ZooKeeper()
}

function createInstance<A extends Animal>(c: new () => A) :A{
  return new c()
}

createInstance(Lion).keeper.nametag
createInstance(Lion).bymLegs
createInstance(Bee).keeper.hasMask
/* createInstance(BeeKeeper) */